<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<SCRIPT LANGUAGE="JavaScript">

function chkData(text){ 
tmp =document.all.item("text").value;
if (tmp != "")
reportform.submit();
else {
alert("Enter Name");
document.all.item("text").focus();
}
}
</SCRIPT>
</head>

<body>
<div id="Layer31">
  <table width="983" height="58" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td height="39" colspan="4">
	  <p class="style30">ออกรายงาน</p>
        <hr />
        <p>&nbsp;</p>
      </div></td>
    </tr>
    <tr>
      <td width="143" height="19">
	  <form name="reportform" method="post" action="Report System.php">
		<div align="center">ค้นหา</div>
		</td>
      <td width="65"><div align="center">
        <select name="selectreport">
		<option selected="selected">แบ่งตามประเภทผลงาน</option>
          <option>แบ่งตามสาขา</option>
		  <option>แบ่งตามรายวิชา</option>
          </select>                                        
      </div></td>
      <td width="601">
        <div align="center">
          <input type="text" size="90" name="text" />
        </div>
        </label>
      </form></td>
      <td width="174"><div align="center">
          <label>
          <div align="left">
            <input type="button" name="btn" value="ค้นหา" onclick="chkData(text)"/>
          </div>
          </label>
        </form>
      </div></td>
    </tr>
	</table>
	<div id="Layer32">
  <table width="900" height="80" border="1" cellpadding="0" cellspacing="0">
    <tr>
      <td width="105" height="46" bgcolor="#0099CC"><div align="center" class="style29">ชื่อสาขา</div></td>
      <td width="157" bgcolor="#0099CC"><div align="center" class="style29">ชื่อรายวิชา</div></td>
      <td width="138" bgcolor="#0099CC"><div align="center" class="style29">ชื่อผู้ใช้</div></td>
      <td bgcolor="#0099CC"><div align="center" class="style29">ชื่อผลงาน</div></td>
      <td width="138" bgcolor="#0099CC"><div align="center" class="style29">ประเภทผลงาน</div></td>
      <td colspan="2" bgcolor="#0099CC"><div align="center" class="style29">สถานะผลงาน</div></td>
    </tr>
<? require("../connectDB.php");    //include "connectdb.inc";
if ($selectreport == "แบ่งตามประเภทผลงาน")
$tmp="select * from project where project_type like '$text%' order by s_id;";
else if ($selectreport == "แบ่งตามสาขา")
$tmp="select * from project where major like '$text%' order by s_id;";
else if ($selectreport == "แบ่งตามรายวิชา")
$tmp="select * from project where subject like '$text%' order by s_id;";
else
$tmp="select * from project;";
//echo($tmp);
$sql = mysql_query($tmp);
while($result = mysql_fetch_array($sql))    { ?>
<TR>
<TD align="center"><? echo $result["major"]; ?></TD>
<td align="center"><? echo $result["subject"]; ?></td>
<td align="center"><? echo $result["name"]; ?></td>
<TD align="center"><? echo $result["project_name"]; ?></TD>
<TD align="center"><? echo $result["project_type"]; ?></td>
<TD align="center"><img src="../Picture/view_icon.jpg" width="35" height="30" /></td>
<TD align="center"><img src="../Picture/printer_icon.png" width="35" height="30" /></td>
</tr>
<? }
mysql_free_result($sql);
mysql_close($con); ?>
</table>
</body>
</html>